/*
 * @Author: zxc
 * @Date: 2020-11-29 13:28:09
 * @LastEditTime: 2020-11-29 18:35:41
 * @LastEditors: zxc
 * @Description:
 */
import * as Koa from "koa"
import * as bodify from "koa-body"
import * as serve from "koa-static"
import * as timing from "koa-xtime"

const app = new Koa()
app.use(serve(`${__dirname}/public`))
app.use(
  bodify({
    multipart: true,
    strict: false //非严格模式允许delete
  })
)

// app.use((ctx:Koa.Context) => {
//   ctx.body = 'hello koa'
// })

import { loader } from "./utils/decors"
import { resolve } from "path"

import { Sequelize } from "sequelize-typescript"

const database = new Sequelize({
  port: 3306,
  database: "test",
  username: "root",
  password: "123456",
  dialect: "mysql",
  modelPaths: [`${__dirname}/model`]
})
const router = loader(resolve(__dirname, "./routes"))
app.use(router.routes())

app.listen(3000, () => console.log("开了"))
